<div class="crayons-card p-3 mb-5 mt-2">

  <header class="flex items-center mb-6">
    <h1 class="crayons-title">Consumer Apps</h1>
    <a href="<%= new_admin_consumer_app_path %>" class="crayons-btn ml-auto" role="button">New Consumer App</a>
  </header>

  <p>
    Consumer apps are standalone mobile apps that users can use to browse <%= Settings::Community.community_name %> as an alternative to web browsers.
  </p>
  <p class="mt-3">
    If the app is listed as <strong>operational</strong>, it means <%= Settings::Community.community_name %> will be able to deliver push notifications directly to users' devices.
  </p>
</div>

<table class="crayons-table" width="100%">
  <thead>
    <tr>
      <th scope="col">App Bundle</th>
      <th scope="col">Platform</th>
      <th scope="col">Devices</th>
      <th scope="col">Authentication Key</th>
      <th scope="col">Operational</th>
      <th scope="col">Actions</th>
    </tr>
  </thead>
  <tbody class="crayons-card">
    <% @apps.each do |app| %>
        <tr>
          <td><%= app.app_bundle %></td>
          <td><%= Device.platforms[app.platform] %></td>
          <td><%= app.devices.count %></td>
          <% if app.auth_credentials.present? %>
            <td><span class="crayons-icon" role="img" aria-label="Authentication Key is available">✅</span></td>
          <% else %>
            <td><span class="crayons-icon" role="img" aria-label="Authentication Key is not available">❌</span></td>
          <% end %>
          <% if app.operational? %>
            <td><span class="crayons-icon" role="img" aria-label="App is Operational">✅</span></td>
          <% else %>
            <td><span class="crayons-icon" role="img" aria-label="App is not Operational">❌</span></td>
          <% end %>
          <td>
            <% if app.forem_app? %>
              <span class="fs-xs">Forem apps are supported by default and can't be modified.</span>
            <% else %>
              <%= link_to "Edit", edit_admin_consumer_app_path(app), class: "crayons-btn crayons-btn--outlined" %>
              <%= link_to "Destroy", admin_consumer_app_path(app), class: "crayons-btn crayons-btn--danger", method: :delete, data: { confirm: "Are you sure?" } %>
            <% end %>
          </td>
        </tr>
    <% end %>
  </tbody>
</table>
